<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">

<head>
    <meta http-equiv="Content-Type" content="multipart/form-data; charset=utf-8" />
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
    <title>设置-个人信息</title>
    <link rel="icon" href="/assets/img/favicon.ico">

    <link rel="stylesheet" type="text/css" href="css/webbase.css"/>
    <link rel="stylesheet" type="text/css" href="css/pages-seckillOrder.css"/>
</head>

<body>
<!--页面顶部白条条，由js动态加载-->
<script type="text/javascript" src="plugins/jquery/jquery.min.js"></script>
<div class="nav-bottom"></div>
<script type="text/javascript">$(".nav-bottom").load("top.html");</script>

<script type="text/javascript" src="js/plugins/jquery/jquery.min.js"></script>
<script type="text/javascript">
    $(function () {
        $("#service").hover(function () {
            $(".service").show();
        }, function () {
            $(".service").hide();
        });
        $("#shopcar").hover(function () {
            $("#shopcarlist").show();
        }, function () {
            $("#shopcarlist").hide();
        });

    })
</script>
<script type="text/javascript" src="js/plugins/jquery.easing/jquery.easing.min.js"></script>
<script type="text/javascript" src="js/plugins/sui/sui.min.js"></script>
<script type="text/javascript" src="js/plugins/jquery-placeholder/jquery.placeholder.min.js"></script>
<script type="text/javascript" src="js/widget/nav.js"></script>
<script type="text/javascript" src="js/plugins/birthday/birthday.js"></script>
<script type="text/javascript" src="js/plugins/citypicker/distpicker.data.js"></script>
<script type="text/javascript" src="js/plugins/citypicker/distpicker.js"></script>
<script type="text/javascript" src="js/plugins/upload/uploadPreview.js"></script>
<script type="text/javascript" src="js/pages/main.js"></script>
<script>
    $(function () {
        $.ms_DatePicker({
            YearSelector: "#select_year2",
            MonthSelector: "#select_month2",
            DaySelector: "#select_day2"
        });
    });
</script>
</body>
<!--header-->
<div id="account">
    <div class="py-container">
        <div class="yui3-g home">
            <!--左侧列表-->
            <div class="yui3-u-1-6 list">

                <div class="person-info" >
                    <div class="person-photo" style="margin:0 auto;"  ><img :src="form.image" alt=""  style="width: 100px;height:100px; border-radius:50px;overflow: hidden;"></div>
                    <br/>
                    <div class="person-account" style="text-align:center" >
                        <span class="name">{{form.name}}</span>
                        <span class="safe">账户安全</span>
                    </div>

                    <div class="clearfix"></div>
                </div>
                <div class="list-items">
                    <dl>
                        <dt><i>·</i> 订单中心</dt>
                        <dd><a href="home-index.html">我的订单</a></dd>
                        <dd><a href="home-order-pay.html">待付款</a></dd>
                        <dd><a href="home-order-send.html">待发货</a></dd>
                        <dd><a href="home-order-receive.html">待收货</a></dd>
                        <dd><a href="home-order-evaluate.html">待评价</a></dd>
                    </dl>
                    <dl>
                        <dt><i>·</i> 我的中心</dt>
                        <dd><a href="home-person-collect.html">我的收藏</a></dd>
                        <dd><a href="home-person-footmark.html">我的足迹</a></dd>
                    </dl>
                    <dl>
                        <dt><i>·</i> 物流消息</dt>
                    </dl>
                    <dl>
                        <dt><i>·</i> 设置</dt>
                        <dd><a href="home-setting-info.html" class="list-active">个人信息</a></dd>
                        <dd><a href="home-setting-address.html">地址管理</a></dd>
                        <dd><a href="home-setting-safe.html">安全管理</a></dd>
                    </dl>
                </div>
            </div>
            <!--右侧主内容-->
            <div class="yui3-u-5-6">
                <div class="body userInfo">
                    <ul class="sui-nav nav-tabs nav-large nav-primary ">
                        <li class="active"><a href="#one" data-toggle="tab">基本资料</a></li>
                        <li><a href="#two" data-toggle="tab">头像照片</a></li>
                    </ul>
                    <div class="tab-content ">
                        <div id="one" class="tab-pane active">
                            <form id="form-msg" class="sui-form form-horizontal" enctype="multipart/form-data">
                                <div class="control-group">
                                    <label for="inputName" class="control-label">昵称：</label>
                                    <div class="controls">
                                        <input type="text" id="inputName" name="email" placeholder="昵称"
                                               v-model="form.name">
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label for="inputGender" class="control-label">性别：</label>
                                    <div class="controls">
                                        <label data-toggle="radio" class="radio-pretty inline">
                                            <input type="radio" name="gender" value="1" id="radio1" :checked="form.gender"
                                                   v-model="form.gender"><span>男</span>
                                        </label>
                                        <label data-toggle="radio" class="radio-pretty inline">
                                            <input type="radio" name="gender" value="0" id="radio2" :checked="form.gender"
                                                   v-model="form.gender"><span>女</span>
                                        </label>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label for="inputPassword" class="control-label">生日：</label>
                                    <div class="controls">
                                        <input v-model="userbirthday" type="hidden">
                                        <select id="select_year2" rel="1990" v-model="y"></select>年
                                        <select id="select_month2" rel="4" v-model="m"></select>月
                                        <select id="select_day2" rel="3" v-model="d"></select>日
                                        </input>
                                    </div>
                                </div>


                                <div class="control-group">
                                    <label for="inputPassword" class="control-label">所在地：</label>
                                    <div class="controls">
                                        <div data-toggle="distpicker">
                                            <input v-model="useraddress" type="hidden">
                                            <div class="form-group area">
                                                <select class="form-control" id="province1" v-model="p"></select>
                                                <select class="form-control" id="city1" v-model="cit"></select>
                                                <select class="form-control" id="district1" v-model="xian"></select>
                                            </div>
                                            </input>
                                        </div>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label for="inputJob" class="control-label">职业：</label>
                                    <div class="controls"><span class="sui-dropdown dropdown-bordered select"><span
                                            class="dropdown-inner"><a role="button" data-toggle="dropdown" href="#"
                                                                      class="dropdown-toggle">
                                                <input name="job" type="hidden" data-rules="required"><i
                                            class="caret"></i><span>请选择</span></a>
                                            <ul id="menu4" role="menu" aria-labelledby="drop4"
                                                class="sui-dropdown-menu">
                                                <li role="presentation"><a role="menuitem" tabindex="-1"
                                                                           href="javascript:void(0);" value="bj">程序员</a></li>
                                                <li role="presentation"><a role="menuitem" tabindex="-1"
                                                                           href="javascript:void(0);"
                                                                           value="sb">产品经理</a></li>
                                                <li role="presentation"><a role="menuitem" tabindex="-1"
                                                                           href="javascript:void(0);"
                                                                           value="sb">UI设计师</a></li>
                                            </ul>
                                            </span>
                                            </span>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label for="sanwei" class="control-label"></label>
                                    <div class="controls">
                                        <button type="submit" class="sui-btn btn-primary" @click.prevent="submitForm">
                                            立即提交
                                        </button>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div id="two" class="tab-pane">

                            <form enctype="multipart/form-data">
                                <tr>
                                <div class="new-photo">
                                    <p>当前头像：</p>
                                    <div class="upload">
                                        <img id="imgShow_WU_FILE_0" width="100" height="100" :src="form.image"
                                             alt="">
                                        <input type="file" id="up_img_WU_FILE_0"    @change="uploadChange($event)"/>
                                    </div>
                                </div>
                                </tr>
                            </form>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>

<script src="./js/vue/vue.js"></script>
<script src="./js/axios.min.js"></script>
<script src="./js/common.js"></script>
<script type="text/javascript">
    var submitFormVm = new Vue({

        el: "#account",
        data: {

            ly,
            y: '',//年
            m: '',//月
            d: '',//日
            date: '',//定义一个日期变量
            p: '',//省
            cit: '', //市
            xian: '',//地区
            address: '',//定义一个变量接受地址
            userDetail: {},
            form: {
                name: '',
                gender: '',
                address: '',
                birthday: '',
                image:'',
            },
        },

        created() {
            this.getUserData();
        },
        methods: {
            submitForm() {
                ly.verify().then(resp => {

                    // 已登录数据传回后台，存入数据库
                    leyou.http.post("user/detail", ly.stringify(this.form));
                    alert("保存成功！");
                }).catch(() => {
                    //未登录购，登陆后转到此页面内，正在他数据提交到后台
                    location.href = "http://www.leyou.com/login.html?returnUrl=" + location.href;
                })
            },
            getUserData() {
                ly.http.get("/user/detail/userDetail").then(({data}) => {

                    // this.p = data.address.split("-")[0];
                    // this.cit = data.address.split("-")[1];
                    // this.xian = data.address.split("-")[2];
                    console.log(data.address.split("-"));
                    this.y = data.birthday.split("-")[0];
                    this.m = data.birthday.split("-")[1];
                    this.d = data.birthday.split("-")[2];
                    this.form.name = data.name;
                    this.form.gender = data.gender;
                    this.form.image = data.image;
                })
            },
            uploadChange(event){
                let file = event.target.files[0];  //提交的图片

                let param = new FormData(); //创建form对象
                param.append('file',file);//通过append向form对象添加数据
                console.log(param.get('file')); //FormData私有类对象，访问不到，可以通过get判断值是否传进去
                let config = {
                    headers:{'Content-Type':'multipart/form-data'}
                };  //添加请求头
                axios.post('/upload/image',param,config).then(response=>{
                    this.form.image = response.data;
                })
            },

        },
        computed: {
            useraddress() {
                //地址的拼接
                this.address = this.p + "-" + this.cit + "-" + this.xian;
                return this.form.address = this.address;
            },
            userbirthday() {
                //日期的拼接
                this.date = this.y + "-" + this.m + "-" + this.d;
                return this.form.birthday = this.date;
            }
        }

    });
</script>
<!-- 底部栏位 -->
<!--页面底部，由js动态加载-->
<div class="clearfix footer"></div>
<script type="text/javascript">$(".footer").load("foot.html");</script>
<!--页面底部END-->
<!--<script>
    // 性别判断
    if(this.form.gender==0){
        $("#radio1").attr("checked","checked");
        $("#radio2").removeAttr("checked");
    }else{
        $("#radio2").attr("checked","checked");
        $("#radio1").removeAttr("checked");
    }
</script>-->

</html>